package day19;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.Socket;

///本类代表网络通信中的客户端
//创建客户端套接字对象
//给服务器发送数据
//接受服务端返回的数据并阅读
//关闭资源
public class Client {
    public static void main(String[] args) throws IOException {
        Socket socket = new Socket("127.0.0.1" , 8888);
        OutputStream out = socket.getOutputStream();
        out.write("Hellow".getBytes());
        out.flush();
        InputStream in = socket.getInputStream();
        for (int i = 0; i < 5; i++) {
            char c = (char)in.read();
            System.out.print(c);
        }
        in.close();
        out.close();
        socket.close();


    }
}
